using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
  public  class NhanVienBUS
    {
        public static void Insert(TBNhanVien NV)
        {
            NhanVienDAL NVDAL = new NhanVienDAL();
            NVDAL.Insert(NV);
        }
        public static void Update(TBNhanVien NV)
        {
            NhanVienDAL NVDAL = new NhanVienDAL();
            NVDAL.Update(NV);
        }
        public static void Delete(int iD)
        {
            NhanVienDAL NVDAL = new NhanVienDAL();
            NVDAL.Delete(iD);
        }
        public static tbNhanVienCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            NhanVienDAL NVDAL = new NhanVienDAL();
            return NVDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbNhanVienCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            NhanVienDAL NVDAL = new NhanVienDAL();
            return NVDAL.Get(cri.Criter, 0, 0, tbNhanVienColumns.MaNV.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBNhanVien GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbNhanVienColumns.MaNV.ToString(), Condition.EQUAL, iD);
            NhanVienDAL NVDAL = new NhanVienDAL();
            tbNhanVienCollection nhanviencollection = NVDAL.Get(cri.Criter,
                  0, 0, tbNhanVienColumns.MaNV.ToString(), OrderDirection.ASC.ToString(), out total);
            if (nhanviencollection.Count > 0)
                return nhanviencollection[0];
            return null;
        }
        public static tbNhanVienCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            NhanVienDAL NVDAL = new NhanVienDAL();
            return NVDAL.Get(cri.Criter, 1, number,
             tbNhanVienColumns.MaNV.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbNhanVienCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            NhanVienDAL NVDAL = new NhanVienDAL();
            return NVDAL.Get(cri.Criter, 1, number,
               tbNhanVienColumns.MaNV.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
